home *** CD-ROM | disk | FTP | other *** search
/ Univers Interactif 3 / INTERACTIF.BIN / pc / planeten / internet / macslip2.6up / MacSLIP Folder / Cisco.script < prev    next >
Text File  |  1995-01-11  |  7KB  |  309 lines

  1. #
  2. # Cisco.script
  3. #
  4. # This script connects to a Cisco terminal setup to require TACACS
  5. # authentication to login and a "SLIP DEFAULT" command to enter
  6. # SLIP mode.
  7. #
  8. # You may need to modify it if you don't need to login with a username
  9. # or password, or if you have a specific IP address assigned for your
  10. # use.
  11. #
  12. # This script is designed to dial a Hayes compatible modem.
  13. #
  14. # The first time this script runs, it will prompt for your username,
  15. # password, and phone number to dial. These settings will be saved
  16. # for subequent connections.
  17. #
  18. # Using default settings, the modem will be initialized before this script
  19. # starts running. Make sure the "Init modem when connecting" option
  20. # is set in the "Modem" menu and that you have made an appropriate
  21. # modem selection.
  22. #
  23. ignore var busygo
  24.  
  25. # If user is not defined, ask for it.
  26. ifdef user goto skipuser
  27. message ""
  28. message "\bEnter your login username."
  29. ask var
  30. define user "$var"
  31. label skipuser
  32.  
  33. # if password is not defined, ask for it
  34. ifdef password goto skippass
  35. message "Will login to SLIP server as $user.\n\bPassword:"
  36. askp var
  37. define /h password "$var"
  38. label skippass
  39.  
  40. # if phone is not defined, ask for it
  41. ifdef phone goto skipphone
  42. message "\bEnter the phone number to dial"
  43. ask var
  44. define phone "$var"
  45. label skipphone
  46.  
  47. # Let the user know we're starting up
  48. label startup
  49. message "Script starting..."
  50. # Setup action handlers
  51. on restart goto restart
  52. on abort goto abort
  53.  
  54. # Dial the phone and wait for the terminal server to send its login
  55. # banner. Some areas support using *70 as a dialing prefix to suppress
  56. # call-waiting tones which will probably cause your modem
  57. # to lose the connection. Some terminal servers may require you to
  58. # autobaud before they will respond. Allow enough time for the modem
  59. # handshake to complete.
  60.  
  61. label dial
  62.  
  63. ifdef INITMODEM goto skipwarn
  64. beep
  65. message "\bYou should select a modem using Configure"
  66. label skipwarn
  67.  
  68. message "Dialing $phone..."
  69. flush
  70. on abort goto hangupabort
  71. send "ATDT $phone\r"
  72. {
  73.     ifmatch "Username:" break
  74.     ifmatch "Login:" break
  75.     ifmatch "login:" break
  76.     ifmatch "NO DIALTONE" goto nodialtone
  77.     ifmatch "NO DIAL TONE" goto nodialtone
  78.     ifmatch "BUSY" goto phonebusy
  79.     ifmatch "NO CARRIER" goto nocarrier
  80.     iftime 1:15 goto dialtimeout
  81. }
  82.  
  83. # Log into the SLIP server. Try three times to send the username. Use
  84. # counter #1 to count the number of login attempts.
  85.  
  86. setcount 1 0
  87. label login
  88. ifcountgt 1 3 goto cantlogin
  89. message "Logging in as $user..."
  90. setcount 0 0
  91. label user
  92. flush
  93. ifcountgt 0 3 goto baduser
  94. send "$user\r"
  95. {
  96.     ifmatch "Password:" break
  97.     ifmatch "password:" break
  98.     ifmatch "Username:" goto user
  99.     ifmatch "login:" goto user
  100.     ifmatch "Login:" goto user
  101.     iftime 10 goto baduser
  102. }
  103.  
  104. # Send the password and wait for the prompt. If we see the
  105. # username prompt again, then we didn't get logged in so try again.
  106.  
  107. message "Sending password..."
  108. flush
  109. send "$password\r"
  110. {
  111.     ifmatch ">" goto setslip
  112.     ifmatch "%" goto setslip
  113.     ifmatch "Access denied" goto accessdenied
  114.     ifmatch "incorrect" goto accessdenied
  115.     iftime 10 goto cantlogin
  116. }
  117.  
  118. # If the login attempt fails, we land here.
  119.  
  120. label accessdenied
  121. {
  122.     ifmatch "Username:" goto login
  123.     ifmatch "Login:" goto login
  124.     ifmatch "login:" goto login
  125.     ifmatch "NO CARRIER" goto cantlogin
  126.     iftime 10 goto cantlogin
  127. }
  128.  
  129. # Setup the slip server. "Terminal download" makes sure that the line
  130. # is setup for eight bit characters, no parity, no interrupt character,
  131. # etc.
  132.  
  133. label setslip
  134. message "Setting terminal line for SLIP operation..."
  135. flush
  136. send "terminal download\r"
  137. {
  138.     ifmatch ">" break
  139.     iftime 10 goto cantsetterm
  140. }
  141.  
  142. # Enable SLIP.  The SLIP server tells us our MTU in bytes, so look for the
  143. # word "bytes" If you aren't using default addresses, change the
  144. # "slip default" command.
  145.  
  146. message "Enabling SLIP mode on server..."
  147. flush
  148. send "slip default\r"
  149. {
  150.     ifmatch "bytes" break
  151.     iftime 10 goto cantstartslip
  152. }
  153.  
  154. # All done.  Send message to alert the user, flush the junk out of the
  155. # receive buffer, and return success.
  156.  
  157. message "Script complete"
  158. flush
  159. return 1
  160.  
  161. # Error handlers.
  162.  
  163. label abort
  164. beep
  165. message "\bCommand-. seen or Cancel button clicked."
  166. goto aborted
  167.  
  168. label hangupabort
  169. beep
  170. message "\bCommand-. seen or Cancel button clicked."
  171. goto hangup
  172.  
  173. label cantfindmodem
  174. beep
  175. message "\bThe modem didn't respond to attention"
  176. message "\bbsignal.  Check modem and cabling."
  177. goto aborted
  178.  
  179. label cantinitmodem
  180. beep
  181. message "\bThe modem didn't respond to initialization"
  182. message "\bstring.  Check the modem."
  183. goto aborted
  184.  
  185. label nodialtone
  186. beep
  187. message "\bThe modem could not detect a dialtone."
  188. message "\bCheck the phone line."
  189. goto aborted
  190.  
  191. label phonebusy
  192. flush
  193. message "\bThe number $phone is busy."
  194. if $busygo eq "go" goto redial
  195. on restart goto busygo
  196. beep
  197. message "\bClick "Restart" to keep trying, "OK" to quit."
  198. ask junk
  199. return 0
  200.  
  201. label busygo
  202. on restart goto restart
  203. set busygo "go"
  204. flush
  205. label redial
  206. do syncmodem
  207. goto dial
  208.  
  209. label nocarrier
  210. beep
  211. message "\bThe modem could not establish a connection."
  212. message "\bMake sure there is a modem on the other end."
  213. goto aborted
  214.  
  215. label dialtimeout
  216. message "\bThe modem or SLIP server isn't responding."
  217. message "\bTry dialing manually to make sure the modem"
  218. message "\band SLIP server are OK."
  219. goto aborted
  220.  
  221. label baduser
  222. beep
  223. message "\bThe SLIP server won't accept a username."
  224. message "\bTry dialing manually to make sure the SLIP"
  225. message "\bserver is OK."
  226. goto hangup
  227.  
  228. label cantlogin
  229. beep
  230. message "\bLogin to SLIP server failed, check username"
  231. message "\band password."
  232. goto hangup
  233.  
  234. label cantsetterm
  235. beep
  236. message "\bCan't set terminal line for SLIP operation."
  237. goto hangup
  238.  
  239. label cantstartslip
  240. beep
  241. message "\bCan't put server into SLIP mode."
  242. goto hangup
  243.  
  244. # General back-end for bailing out.
  245.  
  246. label hangup
  247. do disconnect
  248. # fallthrough into aborted
  249.  
  250. label aborted
  251. message "\bScript aborted!"
  252. message "\bClick "OK" to quit, "Restart" to retry."
  253. # This activates the OK button.
  254. ask junk
  255. flush
  256. return 0
  257.  
  258. # Restart procedure.
  259. # This label is entered when you click the restart button in the
  260. # connection dialog. We try to force the modem to hang up, then we go back
  261. # to the start of the script.
  262.  
  263. label restart
  264. do disconnect
  265. message "\bScript restarted."
  266. goto startup
  267.  
  268. # Disconnect procedure. The "disconect" procedure is called by MacSLIP
  269. # when the "Disconnect" button is clicked. This procedure escapes the
  270. # modem into command mode and hangs up the phone. The +++ escape sequence
  271. # is surrounded by delays that some modems require.
  272.  
  273. label disconnect
  274. send "\d\d+++\d\dATH\r\d\d"
  275. do syncmodem
  276. return 1
  277.  
  278. # Alternate disconnect procedure for modems that drop into command mode
  279. # when DTR is dropped. You may want to try this alternate disconnect
  280. # procedure if the one above doesn't work for your modem. Just swap the
  281. # labels to use this one instead of the one above.
  282.  
  283. label disconnect2
  284. dtr off
  285. delay 3
  286. send "ATH\r"
  287. dtr on
  288. flush
  289. return 1
  290.  
  291. # Attempt to sync up with the modem, but don't wait forever.
  292. label syncmodem
  293. setcount 4 0
  294. flush
  295. label waitmodem2
  296. ifcountgt 4 2 return
  297. send "AT\r"
  298. {
  299.     ifmatch "OK" break
  300.     iftime 2 goto waitmodem2
  301. }
  302. flush
  303. return
  304.  
  305. # for Emacs
  306. #  Local Variables:
  307. #  tab-width: 4
  308. #  End:
  309.